/***
 * @Description:
 * @Author: LI Yihong
 * @Email: liyh@jihua.ac.cn
 * @Date: 2024-10-22 11:15:22
 * @LastEditTime: 2024-10-22 11:15:36
 * @LastEditors: LI Yihong
 * @FilePath: \STM32F407_Board\applications\led\led.h
 */
#pragma once
#include <drivers/pin.h>
#include <memory>
#include <board.h>
#include <rtdevice.h>
#include <drivers/rt_drv_pwm.h>
#include "cxx_thread.h"
#include "cxx_semaphore.h"

using namespace rtthread;
using namespace std;

enum class LED_STATE
{
    ON,
    OFF,
};

class LED : public Thread
{
public:
    using Thread::Thread;

    void run(void *parameter);

private:
    rt_device_pwm *pwm_dev;
    void ledInit();
    void setLed(rt_base_t led, LED_STATE state) const;

public:
    shared_ptr<Semaphore> SemKey_0;
    shared_ptr<Semaphore> SemKey_1;
    shared_ptr<Semaphore> SemKey_2;
    shared_ptr<Semaphore> SemKey_UP;
};
